package zsw.proxy.gdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;



public class GdkHandler<T> implements InvocationHandler {
	
	private T target;
	
	public GdkHandler(Object obj) {
		target=(T) obj;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		String methods=method.getName();
		int i=(int) (Math.random()*3);
		Long t1=System.currentTimeMillis();
		Thread.sleep(i*1000);
		System.out.println(proxy.getClass().getName());
		Object invoke = method.invoke(target, args);
		Long t2=System.currentTimeMillis();
		System.out.println("方法："+methods+"调取完毕，耗时："+(t2-t1));
		return invoke;
	}

}
